News All Tests
Current file: /home/estudydev/workspace/MSP09/web/news/tests/class.node.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 15
2.22 %2.22%
2.22% 1 / 45
 
Node
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 15
2.22 %2.22%
2.22% 1 / 45
 public function Node($id, $parentId, $caption, $description = NULL, $type = NULL, $creatorId = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 12
 public function setChild(&$childref)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function getId()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getParentId()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getCaption()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getDescription()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getChild()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getType()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getCreatorId()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getLeafSum()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getLeafCount()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function countLeafs($getall)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 12
 public function getNodeCount()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 7
 public function hasChildNodes()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function __toString()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1


       1                 : <?php                                                                                                                   
       2                 : /*--------------------------------------------------------------------------+                                           
       3                 : This file is part of eStudy.                                                                                            
       4                 : courses/classes/class.Leaf.inc.php                                                                                      
       5                 : - Modulgruppe:  Kurse                                                                                                   
       6                 : - Beschreibung: Klasse fuer Knoten des Baumes.                                                                          
       7                 : - Version:      0.3, 12/05/06                                                                                           
       8                 : - Autor(en):    Christoph Gockel <christoph.gockel@mni.fh-giessen.de>                                                   
       9                 : +---------------------------------------------------------------------------+                                           
      10                 : This program is free software; you can redistribute it and/or                                                           
      11                 : modify it under the terms of the GNU General Public License                                                             
      12                 : as published by the Free Software Foundation; either version 2                                                          
      13                 : of the License, or any later version.                                                                                   
      14                 : +---------------------------------------------------------------------------+                                           
      15                 : This program is distributed in the hope that it will be useful,                                                         
      16                 : but WITHOUT ANY WARRANTY; without even the implied warranty of                                                          
      17                 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                           
      18                 : GNU General Public License for more details.                                                                            
      19                 : You should have received a copy of the GNU General Public License                                                       
      20                 : along with this program; if not, write to the Free Software                                                             
      21                 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                             
      22                 : +--------------------------------------------------------------------------*/                                           
      23                 :                                                                                                                         
      24                 : /**                                                                                                                     
      25                 :  * <code>Node</code> stellt einen Knoteneintrag im Baum dar.                                                            
      26                 :  * @package eStudy.Courses                                                                                              
      27                 :  * @author Christoph Gockel <christoph.gockel@mni.fh-giessen.de>                                                        
      28                 :  * @version 0.3, 12/05/06                                                                                               
      29                 :  */                                                                                                                     
      30                 :                                                                                                                         
      31                 : class Node                                                                                                              
      32               1 : {                                                                                                                       
      33                 :     /** Die Id des Knoteneintrags. */                                                                                   
      34                 :     var $_id;                                                                                                           
      35                 :     /** Die parentId des Knoteneintrags. */                                                                             
      36                 :     var $_parentId;                                                                                                     
      37                 :     /** Der Titel des Knoteneintrags. */                                                                                
      38                 :     var $_caption;                                                                                                      
      39                 :     /** Die Beschreibung des Knoteneintrags. */                                                                         
      40                 :     var $_description;                                                                                                  
      41                 :     /** Die weiteren Kinder des Knoteneintrags. */                                                                      
      42                 :     var $_child;                                                                                                        
      43                 :     /** Typ des Knotens. */                                                                                             
      44                 :     var $_type;                                                                                                         
      45                 :     /** Typ des Knotens. */                                                                                             
      46                 :     var $_creatorId;                                                                                                    
      47                 :                                                                                                                         
      48                 :     /**                                                                                                                 
      49                 :      * Erstellt ein neues Knotenobjekt mit der Id <code>$id</code> und dem Titel/der Beschriftung <code>$caption</code>.
      50                 :      */                                                                                                                 
      51                 :     function Node($id, $parentId, $caption, $description=NULL, $type=NULL, $creatorId = NULL) {                         
      52               0 :         if ( !is_int($id)) {                                                                                            
      53               0 :             die('Error: id is no integer.');//TODO: bessere Fehlerbehandlung...                                         
      54                 :         }                                                                                                               
      55                 :                                                                                                                         
      56               0 :         if ($caption=='') {                                                                                             
      57               0 :             die('Error: caption should not be empty.');                                                                 
      58                 :         }                                                                                                               
      59                 :                                                                                                                         
      60               0 :         $this->_id          = $id;                                                                                      
      61               0 :         $this->_caption     = $caption;                                                                                 
      62               0 :         $this->_description = $description;                                                                             
      63               0 :         $this->_parentId    = $parentId;                                                                                
      64               0 :         $this->_child       = array();// immer ein feld...selbst wenn nur ein Blatt vorhanden ist                       
      65               0 :         $this->_type        = $type;                                                                                    
      66               0 :         $this->_creatorId   = $creatorId;                                                                               
      67               0 :     }                                                                                                                   
      68                 :                                                                                                                         
      69                 :     /**                                                                                                                 
      70                 :      * Fuegt einen (weiteren) Nachfolger des Knotens ein.                                                               
      71                 :      * @param $childref Die Referenz auf das Objekt was "eingehaengt" werden soll.                                      
      72                 :      */                                                                                                                 
      73                 :     function setChild(&$childref) {                                                                                     
      74               0 :        $this->_child[] =& $childref;                                                                                    
      75               0 :     }                                                                                                                   
      76                 :                                                                                                                         
      77                 :     /**                                                                                                                 
      78                 :      * Gibt die Id des Knoteneintrags zurueck.                                                                          
      79                 :      */                                                                                                                 
      80                 :     function getId()                                                                                                    
      81                 :     {                                                                                                                   
      82               0 :         return $this->_id;                                                                                              
      83                 :     }                                                                                                                   
      84                 :                                                                                                                         
      85                 :     /**                                                                                                                 
      86                 :      * Gibt die parentId des Knoteneintrags zurueck.                                                                    
      87                 :      */                                                                                                                 
      88                 :     function getParentId()                                                                                              
      89                 :     {                                                                                                                   
      90               0 :         return $this->_parentId;                                                                                        
      91                 :     }                                                                                                                   
      92                 :                                                                                                                         
      93                 :     /**                                                                                                                 
      94                 :      * Gibt den Titel des Knoteneintrags zurueck.                                                                       
      95                 :      */                                                                                                                 
      96                 :     function getCaption()                                                                                               
      97                 :     {                                                                                                                   
      98               0 :         return $this->_caption;                                                                                         
      99                 :     }                                                                                                                   
     100                 :                                                                                                                         
     101                 :     /**                                                                                                                 
     102                 :      * Gibt die Beschreibung des Knoteneintrags zur&uuml;ck.                                                            
     103                 :      */                                                                                                                 
     104                 :     function getDescription() {                                                                                         
     105               0 :         return $this->_description;                                                                                     
     106                 :     }                                                                                                                   
     107                 :                                                                                                                         
     108                 :     /**                                                                                                                 
     109                 :      * Gibt die Kinder/Das Kind des Knoteneintrags zurueck.                                                             
     110                 :      */                                                                                                                 
     111                 :     function getChild()                                                                                                 
     112                 :     {                                                                                                                   
     113               0 :         return $this->_child;                                                                                           
     114                 :     }                                                                                                                   
     115                 :                                                                                                                         
     116                 :     /**                                                                                                                 
     117                 :      * Gibt den Typ des Knotens zur&uuml;ck.                                                                            
     118                 :      */                                                                                                                 
     119                 :      function getType() {                                                                                               
     120               0 :         return $this->_type;                                                                                            
     121                 :      }                                                                                                                  
     122                 :                                                                                                                         
     123                 :     /**                                                                                                                 
     124                 :      * Gibt den Typ des Knotens zur&uuml;ck.                                                                            
     125                 :      */                                                                                                                 
     126                 :      function getCreatorId() {                                                                                          
     127               0 :         return $this->_creatorId;                                                                                       
     128                 :      }                                                                                                                  
     129                 :                                                                                                                         
     130                 :     /**                                                                                                                 
     131                 :      * Diese Methode z&auml;hlt die Bl&auml;tter im aktuellen Knoten                                                    
     132                 :      * <strong>und</strong> in <em>allen</em> Unterknoten.                                                              
     133                 :      * @access public                                                                                                   
     134                 :      * @return int Anzahl der Bl&auml;tter                                                                              
     135                 :      */                                                                                                                 
     136                 :     function getLeafSum() {                                                                                             
     137               0 :         return $this->countLeafs(true);                                                                                 
     138                 :     }                                                                                                                   
     139                 :                                                                                                                         
     140                 :     /**                                                                                                                 
     141                 :      * Diese Methode gibt die Anzahl der Bl&auml;tter im aktuellen Knoten                                               
     142                 :      * zur&uuml;ck.                                                                                                     
     143                 :      * @access public                                                                                                   
     144                 :      * @return int Die Anzahl der Bl&auml;tter im Knoten                                                                
     145                 :      */                                                                                                                 
     146                 :     function getLeafCount() {                                                                                           
     147               0 :         return $this->countLeafs(false);                                                                                
     148                 :     }                                                                                                                   
     149                 :                                                                                                                         
     150                 :     /**                                                                                                                 
     151                 :      * Diese Methode z&auml;hlt die Bl&auml;tter vom aktuellen Knoten (und den                                          
     152                 :      * Unterknoten, s. Parameter <code>getall</code>).                                                                  
     153                 :      * @param bool getall Ob Bl&auml;tter in Unterknoten mitgez&auml;hlt werden sollen                                  
     154                 :      * @return int Anzahl der Bl&auml;tter                                                                              
     155                 :      * @access private                                                                                                  
     156                 :      */                                                                                                                 
     157                 :     function countLeafs($getall) {                                                                                      
     158               0 :         $leafCount = 0;                                                                                                 
     159               0 :         foreach ($this->_child as $child) {                                                                             
     160               0 :             if (is_a($child, 'leaf')) {                                                                                 
     161               0 :                 $leafCount++;                                                                                           
     162               0 :             } else if(is_a($child, 'leaf_ecom')) {                                                                      
     163               0 :                 $leafCount++;                                                                                           
     164               0 :             } else {                                                                                                    
     165               0 :                 if ($getall == true) {                                                                                  
     166               0 :                     $leafCount += $child->countLeafs($getall);                                                          
     167               0 :                 }                                                                                                       
     168                 :             }                                                                                                           
     169               0 :         }                                                                                                               
     170               0 :         return $leafCount;                                                                                              
     171                 :     }                                                                                                                   
     172                 :                                                                                                                         
     173                 :     public function getNodeCount() {                                                                                    
     174               0 :         $count = 0;                                                                                                     
     175               0 :         foreach ($this->_child as $child) {                                                                             
     176               0 :             if($child->getType() == 'node' || $child->getType() == 'node_ecom') {                                       
     177               0 :                 $count++;                                                                                               
     178               0 :             }                                                                                                           
     179               0 :         }                                                                                                               
     180               0 :         return $count;                                                                                                  
     181                 :     }                                                                                                                   
     182                 :                                                                                                                         
     183                 :     /**                                                                                                                 
     184                 :      * Gibt TRUE zur&uuml;ck falls der aktuelle Knoten, Knoten als Kinder hat.                                          
     185                 :      * Wenn nicht, FALSE.                                                                                               
     186                 :      */                                                                                                                 
     187                 :      function hasChildNodes() {                                                                                         
     188               0 :         return (count($this->_child) > 0);                                                                              
     189                 :      }                                                                                                                  
     190                 :                                                                                                                         
     191                 :     /**                                                                                                                 
     192                 :      * Die Stringdarstellung des Knoteneintrags.                                                                        
     193                 :      */                                                                                                                 
     194                 :     function __toString()                                                                                               
     195                 :     {                                                                                                                   
     196               0 :         return "Object Node($this->_id, $this->_caption)";                                                              
     197                 :     }                                                                                                                   
     198                 : }                                                                                                                       

Generated by PHPUnit 3.2.21 and Xdebug 2.0.4 at Sat Nov 7 22:04:08 CET 2009.